#!/usr/bin/env python
# -*- coding:utf-8 -*-
# file:do_isPrime.py
# author:张仁
# datetime:2021/6/13 20:44
# software: PyCharm
"""
    判断是否为素数
"""
import math


def isPrime(num) -> bool:
    """
        判断是否为素数
        如果num小于0 会抛出ValueError
    """
    if num < 0:
        raise ValueError(f"num值应该大于0，接收到的为{num}")
    if num == 0 or num == 1:
        return False
    if num == 2:
        return True
    for sub_num in range(2, int(math.sqrt(num)) + 1):
        if num % sub_num == 0:
            return False
    return True
